<template>
	<view>

	</view>
</template>

<script>
	import {
		getCode,
		createMemberInfo
	} from '@/api/index.js'
	export default {
		data() {
			return {
				connectorId: '',
				stationId: ''
			};
		},
		onLoad(option) {
			let str = decodeURIComponent(option.q)
			this.connectorId = str.match(/connectorId=(\S*)&/)[1]
			this.stationId = str.split('stationId=')[1]
			this.getOpenIdFn()
		},
		methods: {
			getOpenIdFn() {
				uni.setStorageSync('isCode', 1)
				getCode().then(res => {
					createMemberInfo({
						openId: res.openid
					}).then(res => {
						if (res.memberId) {
							uni.reLaunch({
								url: '/pages/panda-charge/confirm-charge/index?connectorId=' + this
									.connectorId + '&stationId=' + this.stationId
							})
							return
						}
						uni.reLaunch({
							url: '/pages/login/index'
						})
					})
				})
			}
		}
	}
</script>

<style lang="scss">

</style>